package ly.gupao.edu.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

/**
 * @Author: LiYang
 * @created on: 2018/5/27 17:56
 * @discribe:
 */
public class TcpCLientDemo {

    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 8081);
        //构建输入
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String str = reader.readLine();
        PrintWriter writer = new PrintWriter(socket.getOutputStream());

        //构建输出
        BufferedReader reader1 = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        while(str != "bye"){
            writer.println(str);
            writer.flush();
            System.out.println(reader1.readLine());
        }
        socket.close();
    }
}
